/*
 * @lc app=leetcode.cn id=680 lang=cpp
 *
 * [680] 验证回文字符串 Ⅱ
 */

// @lc code=start
class Solution
{
public:
  bool validPalindrome(string s)
  {
    int L = 0, R = s.size() - 1;
    while (L < R && s[L] == s[R]) {
      ++L;
      --R;
    }
    return IsPalindrome(s, L + 1, R) || IsPalindrome(s, L, R - 1);
  }

  bool IsPalindrome(string& s, int begin, int end)
  {
    for (; begin < end; ++begin, --end)
      if (s[begin] != s[end])
        return false;
    return true;
  }
};
// @lc code=end
